home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-30 | 8.0 KB | 213 lines | [TEXT/MPS ] |
- //
- // myCompareProc.r
- //
- // This example installs a copy of the "ReadMe" file to the folder
- // 'Compare Proc Example:' at the root of the selected target volume.
- // Since the same file will be being installed over itself on repeated
- // installations, it will not be possible to see the effects of the
- // file version comparison unless you modify the 'vers' (1) or (2) resource
- // item of the installed file to a higher version, and then save the
- // modified file to the same location. Then on the next installation
- // a dialog will be displayed asking the user "Newer, Older, Cancel".
- // Note that during Easy Install, a newer file will simply not
- // be replaced, while under Custom Install a dialog with choices
- // is presented to the user.
- //
- // This example script uses a custom version compare procedure to
- // check whether a target file about to be replaced is older, newer,
- // or the same version as the file that is about to replace it.
- //
- // A custom version procedure is a code resource, compiled from a
- // seperate source file ( ours is written in C ). That code is linked
- // to a file by declaring an 'invc' resource within the Installer
- // script, that is then referenced from within a file atom ( 'infa' ).
- //
- // A custom version procedure simply returns the version number
- // of the target file based on whatever method the scriptwriter
- // feels is appropriate. A more appropriate name might have been
- // custom Get Version procedure, since the version compare procedure
- // does not actually perform the comparison between files.
- //
- // The Installer will use that returned version number to perform
- // it's usual version comparison. No further action is needed from
- // the custom version compare procedure, once it has returned the
- // version number of the file.
- //
- // The Installer will handle setting up the file for the custom version
- // compare procedure. There is no need to open the file or the file's
- // resource fork from within the version compare procedure. The resource
- // items can be read immediately from within the custom version procedure.
- //
- // Our custom version procedure returns the version number found
- // in the target file's 'vers' (1) resource. If no 'vers' (1)
- // resource item is found in the target file, then the custom version
- // proc will return the 'vers' (2) of the target file. If neither
- // the 'vers' (1) or 'vers' (2) resource is found, then the custom
- // version compare procedure returns 0.
- //
- // This, by the way, is what the Installer normally does anyway, so
- // our custom version procedure isn't really all that valuable in it's
- // present form. You may customize the source code for the provided
- // custom version compare procedure to return the version number of a
- // file as is appropriate for your project needs.
- //
- // You must specify the flags 'useVersProcToCompare' for the custom
- // version procedure to be called from within a file atom ( 'infa' ).
- // You will most likely also want to set the flag 'leaveAloneIfNewer'
- // within your file atom, so that a newer file will not be replaced
- // when installing from Easy Install, and that a dialog asking the
- // user to choose "newer, older, cancel" is provided to the user
- // when a newer target file is encountered during a Custom Install.
- //
- // IMPORTANT: You must either manaully set the source version number
- // within the file atom ( 'infa' ) or create a ScriptCheck extension that
- // computes the value during ScriptChecking process. See the
- // ScriptCheck User's Guide for more information on writing ScriptCheck
- // extensions.
- //
- // You must also create a resource of type 'invc' that specifies the
- // resource type and resource ID of the code resource item containing
- // the custom version procedure. These values are established within
- // the compile ( C ) line of the makefile provided for creating the
- // custom version compare procedure.
- //
- //
- // Copyright 1993-1996, Apple Computer, Inc., All Rights Reserved
- //
-
- #include "InstallerTypes.r"
-
- // include the file containing custom version compare procedure code resource item
- // - note that since this external file is in the form of a file containing
- // already compiled resources, that the include line does not use '#include'
- // and that it is terminated with a semicolon.
- include "GetFileVersion.rsrc";
-
- resource 'inpk' (100) {
- format0 {
- showsOnCustom,
- removable,
- dontForceRestart,
- 0,
- 0,
- "ReadMe to “Compare Proc Example” folder.",
- {
- 'infa', 1000 // file atom using the version compare procedure
- },
- }
- };
-
- resource 'infa' (1000) {
- format1 {
- deleteWhenRemoving,
- deleteWhenInstalling,
- copy,
- dontIgnoreLockedFile,
- dontSetFileLocked,
- useVersProcToCompare, // • Use vers proc
- srcNeedNotExist,
- rsrcForkInRsrcFork,
- leaveAloneIfNewer, // • Do not update a newer file
- updateExisting,
- copyIfNewOrUpdate,
- rsrcFork,
- dataFork,
- 0,
- 0x0,
- 10000, // target file spec
- {
- 20000, // source file spec
- 0,
- 0
- },
-
- 0x04038000, // 4.0.3 • The source version number in BCD format
- // This version number will be used by the version
- // proc specified below to determine whether or not
- // existing target file, if any, should be replaced.
-
- // HINT FOR CREATING THIS VALUE - if you'd like an
- // easy way to determine this hex value, in ResEdit
- // open any file with a version visible from GetInfo .
- // Double click to open a 'vers' resource and note
- // the version displayed. Then open the same 'vers'
- // resource with the ResEdit menu item
- // "Resource/Open using Hex editor" ( you must have
- // a resource item selected ). The first eight digits
- // in the center column are the binary coded decimal
- // form of the 'vers' resource item.
-
-
- 128, // • 'invc' rsrc ID for custom version proc
-
- 0,
- "Example File"
- }
- };
-
- resource 'invc' ( 128 ) {
- format0 {
- 'infn', // The resource type of the actual custom proc
- 128, // The resource id of the actual custom proc
- // NOTE: The code resource type and ID
- // values are specified within the makefile
- // for the compare proc code resource.
- // In this example the lines that create the
- // compare proc code resource are in the same
- // makefile as the one that builds the Installer
- // script. You should use the values specified
- // in the makefile to fill in these fields.
-
- 0, // The minimum amount of memory needed by the proc
- // NOTE: A value of 0 specifies that the Installer's
- // allocated memory will be used by the version
- // compare code resource. Unless your code resource
- // has a specific need for its own memory heap you
- // should always assign this field a value of 0.
-
- "Returns vers 1 or vers 2 version number.",
- }
- };
-
- // target file spec for ReadMe file
- resource 'intf' (10000) {
- format1 {
- noSearchForFile, // use default search path
-
- TypeCrMustMatch, // If this is set to TypeCrMustMatch
- // then a file with a different type
- // and creator than those specified
- // below will not be replaced.
- // If this is set to TypeCrNeedNotMatch
- // then type and creator of an existing
- // target file are ignored.
-
- // The Type and Creator fields will be used to set the
- // file's Type and Creator when a new file is created.
- 'ttro', // TYPE for new file
- 'ttxt', // CREATOR for new file
-
- 0, // finder attribute flags
- // filled by ScriptCheck is value is 0
-
- 1, // creation date for new file
- 1, // modification date for new file
- // NOTE: DATE values are filled
- // by ScriptCheck if the value is 1
-
- 0, // search proc ID ( 'insp' ), none used
-
- ":Compare Proc Example:Example File" // path to target file
- }
- };
-
- // source file spec for Example File file
- resource 'infs' (20000) {
- 'ttro',
- 'ttxt',
- 0x1,
- noSearchForFile,
- TypeCrMustMatch,
- "Disk1:Example File" // path to source file
- };
-